package net.wy.commons.web;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 12-10-15
 * Time: 上午10:49
 * To change this template use File | Settings | File Templates.
 */
public class WebContextFactory {
    private static ThreadLocal<IWebContext> ctxStore = new ThreadLocal();

    public static void setWebContext(IWebContext ctx) {
        ctxStore.set(ctx);
    }

    public static IWebContext getWebContext() {
        IWebContext ctx = (IWebContext) ctxStore.get();
        if (ctx == null) {
            ctx = new WebContextService();
            setWebContext(ctx);
        }
        return (IWebContext) ctxStore.get();
    }
}
